using System.Xml.Schema;

namespace NUnitTest
{
    public class Tests
    {
        [SetUp]
        public void Setup()
        {
        }

        [Test]
        public void Test1()
        {
            Test2();
        }

        private static void Test2()
        {
            string xsdFilePath = @"D:\\RuleConfig\\RulesEngineSchema.xsd";

            XmlSchemaSet schemaSet = new XmlSchemaSet();
            schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);

            schemaSet.Add(null, xsdFilePath);
            XmlSchema schema = null;

            foreach (XmlSchema xs in schemaSet.Schemas())
            {
                schema = xs;
            }

            if (schema != null)
            {
                schema.Write(Console.Out);
            }
        }

        private static void ValidationCallback(object sender, ValidationEventArgs args)
        {
            if (args.Severity == XmlSeverityType.Warning)
                Console.WriteLine("Warning: {0}", args.Message);
            else
                Console.WriteLine("Error: {0}", args.Message);
        }
    }
}